#include "StdAfx.h"
#include "ErrorCountOutput.h"

namespace Test {

ErrorCountOutput::ErrorCountOutput(OutputPtr child) :
	child_(child),
	errorCount_(0)
{
}

ErrorCountOutput::~ErrorCountOutput(void)
{
}

int ErrorCountOutput::getErrorCount(void)
{
	return errorCount_;
}

HtmlOutput* ErrorCountOutput::getHtmlOutput(void)
{
	return dynamic_cast<HtmlOutput*>(child_.get());
}

CompilerOutput* ErrorCountOutput::getCompilerOutput(void)
{
	return dynamic_cast<CompilerOutput*>(child_.get());
}

void ErrorCountOutput::initialize(int tests)
{
	errorCount_ = 0;
	child_->initialize(tests);
}

void ErrorCountOutput::finished(int tests, const Time& time)
{
	child_->finished(tests, time);
}

void ErrorCountOutput::suite_start(int tests, const std::string& name)
{
	child_->suite_start(tests, name);
}

void ErrorCountOutput::suite_end(int tests, const std::string& name, const Time& time)
{
	child_->suite_end(tests, name, time);
}

void ErrorCountOutput::test_start(const std::string& name)
{
	child_->test_start(name);
}

void ErrorCountOutput::test_end(const std::string& name, bool ok, const Time& time)
{
	if (!ok)
	{
		++errorCount_;
	}
	child_->test_end(name, ok, time);
}

void ErrorCountOutput::assertment(const Source& s)
{
	child_->assertment(s);
}

}